package com.sky.module.system.datatrace.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sky.module.system.datatrace.domain.entity.DataTracerEntity;
import com.sky.module.system.datatrace.domain.form.DataTraceQueryForm;
import com.sky.module.system.datatrace.service.DataTraceService;
import com.sky.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @date 2023/3/6 22:37
 **/
@RestController
@RequestMapping("/api/datatrace")
public class DataTraceController {

    @Autowired
    private DataTraceService dataTraceService;

    /***
     * @description 获取分页数据变更历史记录
     * @param dataTraceQueryForm
     * @return com.sky.utils.Result
     * @date 2023/3/9 0:30
     *
     */
    @RequestMapping("query")
    public Result queryPage(@RequestBody DataTraceQueryForm dataTraceQueryForm) {
        Page<DataTracerEntity> page = dataTraceService.queryPage(dataTraceQueryForm);
        return Result.ok(page);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        boolean flag = dataTraceService.deleteById(id);
        if (flag) {
            return Result.ok();
        }
        return Result.error();
    }
}
